{% extends "default/base.html" %}
{% load business_tag %}
{% block content %}
<div class="wrapper wrapper-content">
        <div class="row">
            {% include "ztree/ztree_js.html" %}
            <div class="col-lg-9 animated fadeInRight">
            {% if content_status %}
            <div class="mail-box-header">

                    <div class="row wrapper border-bottom white-bg page-heading">
                        <div class="col-lg-10">
                            <h2>{{ bus_data }}</h2>
                            <ol class="breadcrumb">
                                <li>
                                    <a href="/">首页</a>
                                </li>
                                <li>
                                    <a>{{ bus_data }}</a>
                                </li>
                            </ol>
                        </div>
                        <div class="col-lg-2">

                        </div>
                    </div>
                    <div class="ibox float-e-margins ibox-content">
                            {% include "ztree/active.html" %}
                            <br/>
                            <div id="result">
                                <div class="row">
                                    <div class="col-lg-9">
                                        <p>主要联系人: {{ project.project_contact }} 第二联系人: {{ project.project_contact_backup }}</p>
                                        <ul class="nav nav-pills">
                                            <li ><button href="{% url 'business_host_list' project.uuid %}" class="btn btn-primary btn-action click" >项目环境</button></li>
                                            <li>  <button href="{% url 'business_user_edit' project.uuid %}" class="btn btn-primary btn-action click" >权限管理</button> </li>
{#                                            <li ><button href="{% url 'project_doc' project.id %}" class="btn btn-primary btn-action click">维护文档</button></li>#}
                                            <li ><button href="{% url 'project_edit_ajax' project.uuid %}" class="btn btn-primary btn-action click">项目修改</button></li>
                                        </ul>
                                        <p></p>
                                    </div>
                                </div>
                                <div id="host_rest"><br/><div id="websocket_rest"></div>
                                <div class="clearfix visible-xs-block"></div>
                                <div id="edit_result">
                                    <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" id="select_all" /></th>
                                            <th> eth1 </th>
                                            <th> 机柜 </th>
                                            <th> 业务 </th>
                                            <th> 状态 </th>
                                            <th> 操作 </th>
                                        </tr>
                                    </thead>

                                    {% for i in server_list %}
                                        <tbody>
                                            <tr >
                                                <td width="40"><input type="checkbox" name="node_name" value="{{i.node_name}}"/></td>
                                                <td width="120"> <a href="/assets/host_detail/?uuid={{ i.uuid }}" class="select_node" ><i class="fa fa-linux" style="color:#080506"></i> {{ i.eth1 }} </a></td>
                                                <td width="100">{% if i.room_number %}{{ i.room_number }} {% endif %}{% if i.cabinet %}- {{ i.cabinet }} - {% endif %}{% if i.server_cabinet_id %}{{ i.server_cabinet_id }}{% endif %}</td>
                        {#                                <td width="200">  {% if i.business %}<a href="/assets/server/server_type/{{ i.business.id }}/ ">{{ i.business }}</a>{% endif %}  </td>#}
                                                <td width="100">
                                                {% for s in i.uuid|business_list %}
                                                <a href="/assets/server/server_type/?service_name={{ s }}" class="btn btn-info btn-xs">{{ s }}</a>
                                                {% endfor %}
                                                </td>
                                                <td width="50">
                                                <div class="btn-group tooltip-demo" data-toggle="buttons">
                                                    {% if i.status == 0 %}
                                                        <span class="glyphicon glyphicon-remove"  data-toggle="tooltip" data-placement="bottom" title="未安装系统" aria-hidden="true" style="color: #ff6846"></span>
                                                    {% elif i.status == 1 %}
                                                    <span class="glyphicon glyphicon-ok" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="已安装系统" style="color:#2ad49e"></span>
                                                    {% else %}
                                                    <span class="glyphicon glyphicon-saved" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="安装系统中..." style="color:#2d98d4"></span>
                                                    {% endif %}
                                                </div></td>
                                                <td width="160">
                                                    <div class="tooltip-demo">
                                                    {% if request.user.is_superuser or request.session.fun_auth.edit_host %}
                                                    <a href="/assets/host_edit/?uuid={{ i.uuid }}" class="btn btn-xs btn-primary node-edit" data-toggle="tooltip" data-placement="bottom" title="修改"><i class="fa fa-edit"></i></a>
                                                    {% endif %}
                                                    {% if request.user.is_superuser or request.session.fun_auth.delete_host %}
                                                    <a href="/assets/host_del/?uuid={{ i.uuid }}" class="btn btn-xs btn-danger node-edit" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-trash-o"></i></a>
                                                    {% endif %}
                                                    {% if i.status == 1 and request.user.is_superuser or request.session.fun_auth.update_host %}
                                                    <a href="/assets/update_id/{{ i.uuid }}/" class="btn btn-xs btn-success" data-toggle="tooltip" data-placement="bottom" title="自动上报硬件信息"><i class="fa fa-recycle">更新</i></a>
                                                    {% elif request.user.is_superuser or request.session.fun_auth.update_host %}
                                                        <a href="/assets/update_id/{{ i.uuid }}/" class="btn btn-xs btn-success disabled" data-toggle="tooltip" data-placement="bottom" title="自动上报硬件信息"><i class="fa fa-recycle">更新</i></a>
                                                    {% else %}
                                                    {% endif %}
                                                    {% if request.user.is_superuser or request.session.fun_auth.setup_system %}

                        {#                                        <button type="button" class="btn btn-xs" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</button>#}
                                                        <a href="/assets/server/restart/{{ i.uuid }}/" class="btn btn-xs btn-danger voilet_restart" data-toggle="tooltip" data-placement="bottom" title="重装系统"><i class="fa fa-desktop">装机</i></a>
                                                    {% endif %}
                                                    </div>
                                                </td>
                                            </tr>
                                        </tbody>
                                        {% endfor %}
                                    </table>
                                </div>
                            </div><br/>


                    </div>
                </div>
            </div>
                <div class="mail-box"></div>
            </div>
        </div>
        {% else %}
        <div class="alert alert-dismissable alert-danger">
             <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>
                Alert!
            </h4> <strong>Warning!</strong> 走错地方了吧，或许你的URL不应该是你有权限访问的哦
        </div>
        {% endif %}
        </div>


<script>
// 查询项目参数
    $(function(){
        $(document).on("click",".click",function(e){
              e.preventDefault();
              var url= $(this).attr("href");
              $.ajax({
                  type: "GET",
                  url: url }).done(function( data ) {
                  $("#edit_result").html(data);
              });
              $(".nav-pills >li > button").attr("class", "btn btn-primary btn-action click");
              $(this).attr("class", "btn btn-success btn-action click");
              //return false;
          });
    });

</script>

{% include "ztree/edit_node.html" %}
{% endblock %}